package com.neno.utils;

import com.neno.entity.Person;
import com.neno.service.PersonService;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: root
 * @Date: 2018/11/10 0:28
 */
@Component
public class SchedulerTask {
    public static void main(String[] args) {
        //FileUtils.write();
    }

    @Autowired
    private PersonService personService;

    @Scheduled(cron = "*/5 * * * * ?")
    private void process() {
        String date01 = "2018-11-10 02:20:00";
        String fileName = "D:/002---AllCode/IdeaProjects/goods.txt";
        List<Person> lists = personService.getPersonList(date01);
        // int count = lists.size() - 1;

        NioFileUtils.doWriteAppend(lists, fileName);
        System.out.println("list的大小 : " + lists.size());
        for (Person person : lists) {
            System.out.println(person.toString());
        }
    }
}
